package com.study.feign.hystrix;

import com.alibaba.fastjson.JSON;
import com.study.common.TableId;
import com.study.feign.SecureGoodsClient;
import com.study.goods.SimpleGoodsInfo;
import com.study.vo.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * 商品服务熔断降级兜底
 */
@Slf4j
@Component
public class GoodsClientHystrix implements SecureGoodsClient {
    @Override
    public CommonResponse<List<SimpleGoodsInfo>> getSimpleGoodsInfoByTableId(TableId tableId) {

        log.error("goods client request error in order service :[{}]",
                JSON.toJSONString(tableId));

        return new CommonResponse<>(
                -1,
                "goods client request error",
                Collections.emptyList()
            );

    }
}
